<?php
	include_once '../models/Model.php';
	$model=new Model();
	$name=substr($_POST['name'],-1);
	$room=$model->searchRoomByName($name);
	$roomId=$room->getRoomId();
	//show all booking order
	$order=$model->searchAvailableOrderByRoomID($roomId);
	//cancel all booking order 
	if(count($order)>0)
		foreach ($order as $item)
		{
			$item->setOrderStatus(2);
			$model->updateOrder($item);
		}
	$model->deleteRoom($roomId);
	$date = date("Y-m-d H:i:s");
	$log = $date."---Event---".$roomId."---RoomDeleted\n";
	$path="../log/log.txt";
	$file=fopen($path, "a");
	$write=fwrite($file,$log);
	fclose($file);
	header('Location:'.'../view/manager/room_manager.php');
?>